package view.component.main
{
	import embeds.EmbedRes;
	
	import enums.main.MainNavigatorScreenName;
	import enums.main.UISize;
	
	import feathers.controls.Screen;
	import feathers.controls.ScreenNavigator;
	import feathers.controls.ScreenNavigatorItem;
	
	import starling.display.BlendMode;
	import starling.display.Image;
	
	import view.component.menu.MenuView;
	import view.component.monster.MonsterView;
	import view.component.weapon.WeaponView;
	import view.transition.AnimationNaviTransitionManager;
	
	
	
	/**
	 * 主界面
	 * @author £iang
	 * 
	 */	
	public class MainView extends Screen
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 主导航界面 */
		public var mainNavigator:ScreenNavigator;
		/** Logo图标 */
		public var logoIcon:Image;
		
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化界面 
		 * 
		 */		
		override protected function initialize():void
		{
			var logoIconClass:Class = EmbedRes.MH_LOGO_ICON;
			
			logoIcon = Image.fromBitmap( new logoIconClass(), true );
			logoIcon.scaleX = logoIcon.scaleY = this.dpiScale;
			UISize.DPI_SCALE = this.dpiScale;
			logoIcon.alpha = 0.3;
			logoIcon.blendMode = BlendMode.SCREEN;
			this.addChild( logoIcon );
			
			this.mainNavigator = new ScreenNavigator();
			this.addChild( mainNavigator );
			this.mainNavigator.addScreen(
				MainNavigatorScreenName.LOAD_SCREEN,
				new ScreenNavigatorItem( LoadView,
					{
						open:MainNavigatorScreenName.MENU_SCREEN		
					}
				)
			);
			
			this.mainNavigator.addScreen(
				MainNavigatorScreenName.MENU_SCREEN,
				new ScreenNavigatorItem( MenuView,
					{
						gotoMonster:MainNavigatorScreenName.MONSTER_SCREEN,
						gotoWeapon:MainNavigatorScreenName.WEAPON_SCREEN
					}
				)
			);
			
			this.mainNavigator.addScreen(
				MainNavigatorScreenName.MONSTER_SCREEN,
				new ScreenNavigatorItem( MonsterView,
					{
						back:MainNavigatorScreenName.MENU_SCREEN
					}
				)
			);
			
			this.mainNavigator.addScreen(
				MainNavigatorScreenName.WEAPON_SCREEN,
				new ScreenNavigatorItem( WeaponView,
					{
						back:MainNavigatorScreenName.MENU_SCREEN
					}
				)
			);
			
			
			var transitionManager:AnimationNaviTransitionManager = 
				new AnimationNaviTransitionManager ( mainNavigator, 1.3 );
			
			mainNavigator.showScreen( MainNavigatorScreenName.LOAD_SCREEN );
		}
		
		/**
		 * 绘制函数，调整组件位置 
		 * 
		 */		
		override protected function draw():void
		{
			this.logoIcon.x = UISize.MAIN_W - this.logoIcon.width;
			this.logoIcon.y = UISize.MAIN_H - this.logoIcon.height;
		}
		
		/**
		 * 切换导航栏 
		 * @param screenId 导航栏ID
		 * 
		 */		
		public function showScreen( screenId:String ):void
		{
			mainNavigator.showScreen( screenId );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数 
		 * 
		 */		
		override public function dispose():void
		{
			super.dispose();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function MainView()
		{
			super();
		}
	}
}